import { ApiProperty } from '@nestjs/swagger'
import { IsBoolean, IsEnum, IsNotEmpty, IsOptional } from 'class-validator'
import { TIconType, TMenuStatus, TMenuType } from '@/enum/commom.emun'

export class CreateMenuDto {
  @ApiProperty({
    description: '菜单类型',
    enum: TMenuType,
  })
  @IsEnum(TMenuType, { message: '菜单类型不合法' })
  @IsNotEmpty({
    message: '菜单类型不能为空',
  })
  menuType: TMenuType

  @ApiProperty({
    description: '菜单名称',
    default: '',
  })
  @IsNotEmpty({
    message: '菜单名称不能为空',
  })
  menuName: string

  @ApiProperty({
    description: '路由名称',
    default: '',
  })
  @IsNotEmpty({
    message: '路由名称不能为空',
  })
  routeName: string

  @ApiProperty({
    description: '路由路径',
    default: '',
  })
  @IsNotEmpty({
    message: '路由路径不能为空',
  })
  routePath: string

  @ApiProperty({
    description: '组件路径',
    default: '',
  })
  @IsOptional()
  component: string

  @ApiProperty({
    description: '排序',
    default: 0,
  })
  @IsOptional()
  order: number

  @ApiProperty({
    description: 'i18n字符',
    default: '',
  })
  @IsOptional()
  i18nKey: string

  @ApiProperty({
    description: '菜单图标',
    default: '',
  })
  @IsOptional()
  icon: string

  @ApiProperty({
    description: '图标类型',
    enum: TIconType,
    required: false,
  })
  @IsOptional()
  // @IsEnum(TIconType, { message: '图标类型不合法' })
  iconType: TIconType

  @ApiProperty({
    description: '状态',
    enum: TMenuStatus,
    default: TMenuStatus.enable,
  })
  @IsEnum(TMenuStatus, { message: '状态不合法' })
  status: TMenuStatus

  @ApiProperty({
    description: '父级ID',
    default: null,
  })
  @IsOptional()
  parentId: string

  @ApiProperty({
    description: '是否缓存',
    default: false,
  })
  @IsBoolean()
  keepAlive: boolean

  @ApiProperty({
    description: '是否常量路由',
    default: false,
  })
  @IsBoolean()
  constant: boolean

  @ApiProperty({
    description: '是否外链',
    default: '',
  })
  @IsOptional()
  href: string | null

  @ApiProperty({
    description: '是否隐藏',
    default: false,
  })
  @IsBoolean()
  hideInMenu: boolean

  @ApiProperty({
    description: '高亮菜单名称',
    default: null,
  })
  @IsOptional()
  activeMenu: string | null

  @ApiProperty({
    description: '是否多标签',
    default: false,
  })
  @IsBoolean()
  multiTab: boolean

  @ApiProperty({
    description: '固定在页签中的序号',
    default: null,
  })
  @IsOptional()
  fixedIndexInTab: number | null

  @ApiProperty({
    description: '路由参数',
    default: null,
  })
  @IsOptional()
  query: { key: string; value: string }[] | null

  @ApiProperty({
    description: '页面按钮',
    default: null,
  })
  @IsOptional()
  buttons: { code: string; desc: string }[] | null
}
